package com.day18me.hom;

import java.util.HashSet;
import java.util.Set;

public class TestBook {
    public static void main(String[] args) {
        Set set =  new HashSet();

        Book book = new Book("西游记","吴承恩",66.3);
        Book book1 = new Book("三国演义","罗贯中",75.4);
        Book book2 = new Book("水浒传","施耐庵",45.6);
        Book book3 = new Book("红楼梦","曹雪芹",94.4);
        Book book4 = new Book("曹雪芹","红楼梦",94.4);
//先利用HashCod进行运算，算出元素的哈希地址，判断相同然后再利用equals进行比较元素内容是否相同，相同则不执行添加，不同则执行添加
        set.add(book);
        set.add(book1);
        set.add(book2);
        set.add(book3);
        set.add(book4);
        System.out.println(set);
        System.out.println(set.size());

        for(Object o: set){
            System.out.println(o);
        }

    }
}
